import { Editor } from "./editor";

export function EditorCamera( editor:Editor ) {

	const signals = editor.signals;

	//

	const select = document.createElement('select');
	select.className='tezero-camera-select';
  select.style.position='absolute';
  select.style.right='60px';
  select.style.top='10px';

  select.value=editor.viewportCamera.uuid;

	select.onchange=()=>{
		editor.setViewportCamera( select.value );

	};

  signals.cameraAdded.add(update);
  signals.cameraRemoved.add(update);

	update();

	//

	function update() {
		const cameras = editor.cameras;
    select.innerHTML='';
		for ( const key in cameras ) {

			const camera = cameras[ key ];
      const option=document.createElement('option');
      option.value=camera.uuid;
      option.innerText=camera.name;
      select.appendChild(option);
		}
    select.value=editor.viewportCamera.uuid;

	}

	return select;

}